package oohomework;

public class PolyDemo {
    public static void main(String[] args) {
        Animal[] animals = new Animal[5];
        animals[0]=new Chick("xiaoji",2,"yellow");
        animals[1]=new Fish("yu",3,"red");
        animals[2]=new Chick("xiaoji",1,"yellow");
        animals[3]=new Dog("hei",4,"black");
        animals[4]=new Chick("xiaoji",3,"yellow");
        for(int i=0; i<animals.length; i++)
        {
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if(animals[i] instanceof Dog)
            {
                ((Dog) animals[i]).lookHome();
            }
            if(animals[i] instanceof Chick)
            {
                ((Chick) animals[i]).layEggs();
            }
            if(animals[i] instanceof Swim)
            {
                ((Swim) animals[i]).swim();
            }
        }
    }
}
